package com.killer.redissessiondemo.controller;

import com.killer.redissessiondemo.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
@RequestMapping("/user")
public class UserController {

    @RequestMapping("login")
    public void login(HttpServletRequest request, HttpServletResponse response,String username, String password) throws IOException {
        User user=new User();
        user.setUsername(username);
        //将该user放到session中
        HttpSession session = request.getSession();
        System.out.println(session.getId());
        session.setAttribute("loginUser", user);
        response.sendRedirect("/index.html");
    }


}
